package com.ibangnuo.manage.controller.system;

import com.ibangnuo.api.system.SysDictionaryControllerApi;
import com.ibangnuo.framework.domain.system.SysDictionary;
import com.ibangnuo.framework.model.response.ObjectResult;
import com.ibangnuo.framework.model.response.QueryResponseResult;
import com.ibangnuo.framework.model.response.ResponseResult;
import com.ibangnuo.manage.service.system.SysDictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author: wwy
 * @Date: 2019-12-21 10:44
 */
@RestController
@RequestMapping("/system/dictionary")
public class SysDictionaryController implements SysDictionaryControllerApi {
    @Autowired
    private SysDictionaryService sysDictionaryService;
    /**
     * 查询全部
     * @return
     */
    @GetMapping("/findAll")
    @Override
    public QueryResponseResult findAll() {
        return sysDictionaryService.findAll();
    }

    /**
     * 添加
     * @param sysDictionary
     * @return
     */
    @PostMapping("/add")
    @Override
    public ResponseResult add(@RequestBody SysDictionary sysDictionary) {
        return sysDictionaryService.add(sysDictionary);
    }

    /**
     * 根据id查找
     * @param id
     * @return
     */
    @GetMapping("/get/{id}")
    @Override
    public ObjectResult<Map> findById(@PathVariable("id") String id) {
        return sysDictionaryService.findById(id);
    }

    /**
     * 根据id查找
     * @param type
     * @return
     */
    @GetMapping("/findByType/{type}")
    @Override
    public ObjectResult<Map> findByType(@PathVariable("type") String type) {
        return sysDictionaryService.findByType(type);
    }

    /**
     * 根据id删除
     * @param id
     * @return
     */
    @DeleteMapping("/delete/{id}")
    @Override
    public ResponseResult delete(@PathVariable("id") String id) {
        return sysDictionaryService.delete(id);
    }

    /**
     * 根据id更新
    * @param id
     * @param sysDictionary
     * @return
     */
    @PutMapping("/update/{id}")
    @Override
    public ResponseResult update(@PathVariable("id") String id, @RequestBody SysDictionary sysDictionary) {
        return sysDictionaryService.update(id,sysDictionary);
    }
}
